package demo1;

public class Account {
    private String owner;
    private double balance = 0;
    private AccountState state;

    public Account(String owner, double init) {
        this.owner = owner;
        this.balance = init;
        this.state = new NormalState(this); // 初始状态为NormalState
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public AccountState getState() {
        return state;
    }

    public void setState(AccountState state) {
        this.state = state;
    }

    public void deposit(double amount) {
        state.deposit(amount);
    }

    public void withdraw(double amount) {
        state.withdraw(amount);
    }

    public void computeInterest() {
        state.computeInterest();
    }

    public void stateCheck() {
        state.stateCheck();
    }
}